/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Folder;
import org.xtext.example.cr.cR.LinuxFolder;
import org.xtext.example.cr.cR.WindowsFolder;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Folder</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.FolderImpl#getLinuxFolder <em>Linux Folder</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.FolderImpl#getWindowsFolder <em>Windows Folder</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FolderImpl extends MinimalEObjectImpl.Container implements Folder
{
  /**
   * The cached value of the '{@link #getLinuxFolder() <em>Linux Folder</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLinuxFolder()
   * @generated
   * @ordered
   */
  protected LinuxFolder linuxFolder;

  /**
   * The cached value of the '{@link #getWindowsFolder() <em>Windows Folder</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getWindowsFolder()
   * @generated
   * @ordered
   */
  protected WindowsFolder windowsFolder;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected FolderImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.FOLDER;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public LinuxFolder getLinuxFolder()
  {
    return linuxFolder;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetLinuxFolder(LinuxFolder newLinuxFolder, NotificationChain msgs)
  {
    LinuxFolder oldLinuxFolder = linuxFolder;
    linuxFolder = newLinuxFolder;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.FOLDER__LINUX_FOLDER, oldLinuxFolder, newLinuxFolder);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setLinuxFolder(LinuxFolder newLinuxFolder)
  {
    if (newLinuxFolder != linuxFolder)
    {
      NotificationChain msgs = null;
      if (linuxFolder != null)
        msgs = ((InternalEObject)linuxFolder).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.FOLDER__LINUX_FOLDER, null, msgs);
      if (newLinuxFolder != null)
        msgs = ((InternalEObject)newLinuxFolder).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.FOLDER__LINUX_FOLDER, null, msgs);
      msgs = basicSetLinuxFolder(newLinuxFolder, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.FOLDER__LINUX_FOLDER, newLinuxFolder, newLinuxFolder));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public WindowsFolder getWindowsFolder()
  {
    return windowsFolder;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetWindowsFolder(WindowsFolder newWindowsFolder, NotificationChain msgs)
  {
    WindowsFolder oldWindowsFolder = windowsFolder;
    windowsFolder = newWindowsFolder;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.FOLDER__WINDOWS_FOLDER, oldWindowsFolder, newWindowsFolder);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setWindowsFolder(WindowsFolder newWindowsFolder)
  {
    if (newWindowsFolder != windowsFolder)
    {
      NotificationChain msgs = null;
      if (windowsFolder != null)
        msgs = ((InternalEObject)windowsFolder).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.FOLDER__WINDOWS_FOLDER, null, msgs);
      if (newWindowsFolder != null)
        msgs = ((InternalEObject)newWindowsFolder).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.FOLDER__WINDOWS_FOLDER, null, msgs);
      msgs = basicSetWindowsFolder(newWindowsFolder, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.FOLDER__WINDOWS_FOLDER, newWindowsFolder, newWindowsFolder));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.FOLDER__LINUX_FOLDER:
        return basicSetLinuxFolder(null, msgs);
      case CRPackage.FOLDER__WINDOWS_FOLDER:
        return basicSetWindowsFolder(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.FOLDER__LINUX_FOLDER:
        return getLinuxFolder();
      case CRPackage.FOLDER__WINDOWS_FOLDER:
        return getWindowsFolder();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.FOLDER__LINUX_FOLDER:
        setLinuxFolder((LinuxFolder)newValue);
        return;
      case CRPackage.FOLDER__WINDOWS_FOLDER:
        setWindowsFolder((WindowsFolder)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.FOLDER__LINUX_FOLDER:
        setLinuxFolder((LinuxFolder)null);
        return;
      case CRPackage.FOLDER__WINDOWS_FOLDER:
        setWindowsFolder((WindowsFolder)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.FOLDER__LINUX_FOLDER:
        return linuxFolder != null;
      case CRPackage.FOLDER__WINDOWS_FOLDER:
        return windowsFolder != null;
    }
    return super.eIsSet(featureID);
  }

} //FolderImpl
